package org.common.dynamicbean;

import java.io.Serializable;


/**
 *
 * @author gus
 */
public class DynamicProperty implements Serializable
{
    private static final long serialVersionUID = 5213914761409289854L;

    
    private DynamicPropertySet parent;
    
    protected String displayName;
    protected String name;
    
    protected Class type;
    protected Object value;
   
    public DynamicProperty( String name, Class type, Object value ) throws Exception
    {
        this(name, name, type, value);
    }

    public DynamicProperty( String name, String displayName, Class type )  throws Exception
    {
        this( name, displayName, type, null );
    }

    public DynamicProperty( String name, String displayName, Class type, Object value )
    {
        this.displayName = displayName;
        this.name = name;
        this.type = type;
        this.value = value;
    }


    
    public String getDisplayName()
    {
        return displayName;
    }

    public void setDisplayName( String displayName )
    {
        this.displayName = displayName;
    }

    public String getName()
    {
        return name;
    }

    public void setName( String name )
    {
        this.name = name;
    }

    public Class getType()
    {
        return type;
    }

    public void setType( Class type )
    {
        this.type = type;
    }

    public Object getValue()
    {
        return value;
    }

    public void setValue( Object value )
    {
        Object oldValue = this.value;
        this.value = value;
        if( parent != null )
        {
            parent.firePropertyChange( name, oldValue, value );
        }
    }
  
    public DynamicPropertySet getParent()
    {
        return parent;
    }

    public void setParent( DynamicPropertySet parent )
    {
        this.parent = parent;
    }
}


